package com.bdqn.listener;

import com.bdqn.thread.FileDeleteThread;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.List;

@WebListener
public class BlogSessionListener  implements HttpSessionListener {


    @Override
    public void sessionCreated(HttpSessionEvent sessionEvent) {
        System.out.println("监听器执行创建会话"+sessionEvent.getSession().getId());
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent sessionEv) {
        System.out.println("监听器执行结束会话");
        List<String>  list = (List<String>) sessionEv.getSession().getAttribute("tempArticleFname");
        if (list!=null && list.size()>0 ){
            FileDeleteThread thread = new FileDeleteThread(list,sessionEv.getSession());
            thread.start();
        }
    }

}
